# -*- coding: utf-8 -*-
class MotherboardsController < ApplicationController
	skip_before_filter :authorize , only: [:show, :index] 
  # GET /motherboards
  # GET /motherboards.json
  def index
    @motherboards = Motherboard.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @motherboards }
    end
  end

  # GET /motherboards/1
  # GET /motherboards/1.json
  def show
    @motherboard = Motherboard.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @motherboard }
    end
  end

  # GET /motherboards/new
  # GET /motherboards/new.json
  def new
    @motherboard = Motherboard.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @motherboard }
    end
  end

  # GET /motherboards/1/edit
  def edit
    @motherboard = Motherboard.find(params[:id])
  end

  # POST /motherboards
  # POST /motherboards.json
  def create
    @motherboard = Motherboard.new(params[:motherboard])

    respond_to do |format|
      if @motherboard.save
        format.html { redirect_to @motherboard, notice: 'Se añadió la placa base de forma satisfactoria.' }
        format.json { render json: @motherboard, status: :created, location: @motherboard }
      else
        format.html { render action: "new" }
        format.json { render json: @motherboard.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /motherboards/1
  # PUT /motherboards/1.json
  def update
    @motherboard = Motherboard.find(params[:id])

    respond_to do |format|
      if @motherboard.update_attributes(params[:motherboard])
        format.html { redirect_to @motherboard, notice: 'Se actualizaron los datos de la placa base de forma satisfactoria.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @motherboard.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /motherboards/1
  # DELETE /motherboards/1.json
  def destroy
    @motherboard = Motherboard.find(params[:id])
    @motherboard.destroy

    respond_to do |format|
      format.html { redirect_to motherboards_url }
      format.json { head :no_content }
    end
  end
end
